const constant = require("../../util/constant.js");
const util = require('../../util/util.js');
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        jzlist:[],
        searchvalue:'',
        issel:0,
        index: 0,
        isno:0,
        imgurls:[],
        imgpath:constant.host+"/content/jyjzimg/"+constant.cityid+"/",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },
    inputoperation: function (e) {
        this.setData({
          searchvalue: e.detail.value
          // searchvalue: this.data.searchvalue.concat(e.detail.value)
        })
      },
    handleSubmit: function (event) {
        var that=this;
        var carnumber = that.data.searchvalue;
        //console.log(carnumber)
        if (carnumber == '') {
            util.showFailToast({
              title: '请输入车牌号'
            });
      
            return;
          }
        
        wx.request({
            url: constant.host+'/appserv/selwtlist.ashx',
            data: {
                car:carnumber,
              k: constant.wkey
            },
            success: function (data) {
              var dat = data.data;
                
              //console.log("sl:"+dat.length); 
              //console.log(dat);
              let ishas=0;
              let nohas=0;
              var ajimgs=[];
             
              if(dat.length>0)
              {
                  ishas=1;
                  nohas=0;
                  //console.log(dat[0].AJImg);
                  if(dat[0].AJImg!=null && dat[0].AJImg.length>0)
                  {
                      ajimgs=dat[0].AJImg.split(',');
                      //console.log(ajimgs.length)
                  }
                  
              }
              else
              {
                  nohas=1;
              }
             
              that.setData({
                  issel:ishas,
                  isno:nohas,
                  imgurls:ajimgs,
                jzlist:dat
              });
            }
          });
      },
      ViewImage(e) {
        //console.log(e.currentTarget.dataset.url)
        var urls=this.data.imgurls;
        var imgpath=this.data.imgpath;
        var imgs=[];
        for(var i=0;i<urls.length;i++)
        {
            var myurl=imgpath+urls[i];
            imgs.push(myurl);
        }
  
      wx.previewImage({
        urls: imgs,
        current: imgpath+e.currentTarget.dataset.url
      });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})